-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
makesyscalls: restore support for cpp in input #1575
base: main
Are you sure you want to change the base?
Conversation
CC @agge3 |
I suspect we also need ifdefs in syscalls.map, but I wanted to start with replicating what's in the old version. |
This exercises some subset of the preprocessor that would be nice to still support.
Allow patterns like this in syscalls.master: #if 0 91 AUE_NULL RESERVED #else 91 AUE_NULL STD|CAPENABLED { int newsyscall(void); } #endif makesyscalls.lua and it's predecessor makesyscalls.sh (really an awk script with a tiny shell prolog) used a single pass parsing model where lines beginning with `#` were emitted into most generated files as they were read. I belive this was initially there to allow includes to be listed in syscalls.master, but Hyrum's Law[0] applies and people are using it for things like architecture-specific syscall definitions. This use of CPP macro is unsound and there are a number of sharp edges in both the new and old implementations. The macros are unsound because not all the files were generate are run through CPP (or if they are not in the same context) and this will increasingly be true as we generate more things. Sharp edges include the fact that anything before the first syscall would be printed at a different scope (e.g., before an array is declared). In this patch I collect each non-#include CPP directive and attach them to the syscall table or individual entries. All entries before the first syscall and after the last are attached to the prolog and epilog members. Within the syscall table all entries are attached to the next system calls's prolog member. In generators, each prolog entry is printed regardless of the system call's visibiilty which replicates the naive single pass model's behavior (including lots of empty blocks of #if/#else/#endif in the output). Unlike makesyscalls.lua, I discard none #define entries at the top of the file and print a warning as their usefulness appears limited. [0] https://www.hyrumslaw.com Reported by: kevans Sponsored by: DARPA, AFRL
Warn that C preprocessor directives in the config file are deprecated. They are unsound and support has a number of potential pitfalls. They should be replaced by compile-time generation of files plus an overlay framework to allow things like per-arch variation. Sponsored by: DARPA, AFRL
If there are per-platform differences in which syscalls are supported, we should only try to export implemented ones in libc. Fortunately, syscall maps are run though cpp. (This is arguably incomplete as syscall.mk isn't--and can't practically be--supported.) Sponsored by: DARPA, AFRL
The two outer blocks had identical contents and the two inner blocks differed in a single location. Sponsored by: DARPA, AFRL
db67977
to
2cf57ad
Compare
Pulled in @kevans91's test script and updated for main (I should probably MFC the diff reduction changes.) Fixed the way the epilogue is handled. Added syscalls.map cpp support and added an unrelated minor improvement to the syscall.mk code. |
On the topic of adding tests, I've also added tests: 0934b91. The tests are directed at the parser. They confirm correct parsing by tokenizing both the data that Please let me know if the tests, The other parts of the commit are for applications to qemu-bsd-user and likely should be a different PR (which Warner is helping me with). Not to derail the topic though, just more context. I wanted to bring up the tests, as a lot of tests have now been introduced in this PR. I could pursue my tests to more refinement to add onto that theme (i.e., coping with the preprocessor directives here, make integration, addressing xxx, all ABIs, not printing to stdout, etc.). |
Implement functionality largely identical to that in makesyscalls.lua on 14-STABLE. I've excluded prolog and epilogue support as it's not obviously very useful. Could restore the original function if someone is using conditional includes or the like.
Deprecate this functionality (no plan to remove it without replacement, but putting a line in the sand.)